public class ChainPatternDemo {
    private static AbstractLogger getChainOfLoggers(){
        AbstractLogger errorLogger = new ErrorLogger(AbstractLogger.ERROR);
        AbstractLogger fileLogger = new FileLogger(AbstractLogger.DEBUG);
        AbstractLogger consoleLogger = new ConsoleLogger(AbstractLogger.INFO);

        errorLogger.setNextLogger(fileLogger);
        fileLogger.setNextLogger(consoleLogger);

        return errorLogger;
    }

    public static void main(String[] args) {
        AbstractLogger abstractLogger = getChainOfLoggers();

        abstractLogger.logMessage(AbstractLogger.INFO, "这是一个info");
        abstractLogger.logMessage(AbstractLogger.DEBUG, "这是一个debug");
        abstractLogger.logMessage(AbstractLogger.ERROR, "这是一个error");
    }
}
